package com.bwie.auth.controller;

import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.UserRequest;
import com.bwie.common.domain.response.UserResponse;
import com.bwie.common.result.Result;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：ShenJiaFeng
 * @Package：com.bwie.auth.controller
 * @Project：zg5_19
 * @name：AuthController
 * @Date：2024/2/17 14:30
 */
@RestController
@RequestMapping("/auth")
public class AuthController {
    private final AuthService authService;

    public AuthController(AuthService authService) {
        this.authService = authService;
    }

    @PostMapping("/login")
    public Result<UserResponse> login(@RequestBody UserRequest userRequest){
        return authService.login(userRequest);
    }

    @GetMapping("/userInfo")
    public Result<User> userInfo(){
        return Result.success(
          authService.userInfo()
        );
    }

    @PostMapping("/deleteToken")
    public void deleteToken(){
        authService.deleteToken();
    }


//    @PostMapping("/sendCode")
//    public Result sendCode(@RequestParam String userName){
//        return authService.sendCode(userName);
//    }
}
